home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 123SIEK (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  5.3 KB  |  322 lines

  1. package java.io;
  2.  
  3. public class PrintWriter extends Writer {
  4.    private Writer out;
  5.    private boolean autoFlush;
  6.    private boolean trouble;
  7.    private String lineSeparator;
  8.  
  9.    public PrintWriter(OutputStream out) {
  10.       this(out, false);
  11.    }
  12.  
  13.    public PrintWriter(OutputStream out, boolean autoFlush) {
  14.       this((Writer)(new BufferedWriter(new OutputStreamWriter(out))), autoFlush);
  15.    }
  16.  
  17.    public PrintWriter(Writer out) {
  18.       this(out, false);
  19.    }
  20.  
  21.    public PrintWriter(Writer out, boolean autoFlush) {
  22.       super(out);
  23.       this.autoFlush = false;
  24.       this.trouble = false;
  25.       this.out = out;
  26.       this.autoFlush = autoFlush;
  27.       this.lineSeparator = System.getProperty("line.separator");
  28.    }
  29.  
  30.    public boolean checkError() {
  31.       if (this.out != null) {
  32.          this.flush();
  33.       }
  34.  
  35.       return this.trouble;
  36.    }
  37.  
  38.    public void close() {
  39.       try {
  40.          synchronized(super.lock) {
  41.             if (this.out == null) {
  42.                return;
  43.             }
  44.  
  45.             this.out.close();
  46.             this.out = null;
  47.          }
  48.       } catch (IOException var3) {
  49.          this.trouble = true;
  50.       }
  51.  
  52.    }
  53.  
  54.    private void ensureOpen() throws IOException {
  55.       if (this.out == null) {
  56.          throw new IOException("Stream closed");
  57.       }
  58.    }
  59.  
  60.    public void flush() {
  61.       try {
  62.          synchronized(super.lock){}
  63.  
  64.          try {
  65.             this.ensureOpen();
  66.             this.out.flush();
  67.          } catch (Throwable var4) {
  68.             throw var4;
  69.          }
  70.       } catch (IOException var5) {
  71.          this.trouble = true;
  72.       }
  73.  
  74.    }
  75.  
  76.    private void newLine() {
  77.       try {
  78.          synchronized(super.lock){}
  79.  
  80.          try {
  81.             this.ensureOpen();
  82.             this.out.write(this.lineSeparator);
  83.             if (this.autoFlush) {
  84.                this.out.flush();
  85.             }
  86.          } catch (Throwable var5) {
  87.             throw var5;
  88.          }
  89.       } catch (InterruptedIOException var6) {
  90.          Thread.currentThread().interrupt();
  91.       } catch (IOException var7) {
  92.          this.trouble = true;
  93.       }
  94.  
  95.    }
  96.  
  97.    public void print(char[] s) {
  98.       this.write(s);
  99.    }
  100.  
  101.    public void print(char c) {
  102.       this.write(String.valueOf(c));
  103.    }
  104.  
  105.    public void print(double d) {
  106.       this.write(String.valueOf(d));
  107.    }
  108.  
  109.    public void print(float f) {
  110.       this.write(String.valueOf(f));
  111.    }
  112.  
  113.    public void print(int i) {
  114.       this.write(String.valueOf(i));
  115.    }
  116.  
  117.    public void print(long l) {
  118.       this.write(String.valueOf(l));
  119.    }
  120.  
  121.    public void print(Object obj) {
  122.       this.write(String.valueOf(obj));
  123.    }
  124.  
  125.    public void print(String s) {
  126.       if (s == null) {
  127.          s = "null";
  128.       }
  129.  
  130.       this.write(s);
  131.    }
  132.  
  133.    public void print(boolean b) {
  134.       this.write(b ? "true" : "false");
  135.    }
  136.  
  137.    public void println() {
  138.       synchronized(super.lock){}
  139.  
  140.       try {
  141.          this.newLine();
  142.       } catch (Throwable var3) {
  143.          throw var3;
  144.       }
  145.  
  146.    }
  147.  
  148.    public void println(char[] x) {
  149.       synchronized(super.lock){}
  150.  
  151.       try {
  152.          this.print(x);
  153.          this.newLine();
  154.       } catch (Throwable var4) {
  155.          throw var4;
  156.       }
  157.  
  158.    }
  159.  
  160.    public void println(char x) {
  161.       synchronized(super.lock){}
  162.  
  163.       try {
  164.          this.print(x);
  165.          this.newLine();
  166.       } catch (Throwable var4) {
  167.          throw var4;
  168.       }
  169.  
  170.    }
  171.  
  172.    public void println(double x) {
  173.       synchronized(super.lock){}
  174.  
  175.       try {
  176.          this.print(x);
  177.          this.newLine();
  178.       } catch (Throwable var5) {
  179.          throw var5;
  180.       }
  181.  
  182.    }
  183.  
  184.    public void println(float x) {
  185.       synchronized(super.lock){}
  186.  
  187.       try {
  188.          this.print(x);
  189.          this.newLine();
  190.       } catch (Throwable var4) {
  191.          throw var4;
  192.       }
  193.  
  194.    }
  195.  
  196.    public void println(int x) {
  197.       synchronized(super.lock){}
  198.  
  199.       try {
  200.          this.print(x);
  201.          this.newLine();
  202.       } catch (Throwable var4) {
  203.          throw var4;
  204.       }
  205.  
  206.    }
  207.  
  208.    public void println(long x) {
  209.       synchronized(super.lock){}
  210.  
  211.       try {
  212.          this.print(x);
  213.          this.newLine();
  214.       } catch (Throwable var5) {
  215.          throw var5;
  216.       }
  217.  
  218.    }
  219.  
  220.    public void println(Object x) {
  221.       synchronized(super.lock){}
  222.  
  223.       try {
  224.          this.print(x);
  225.          this.newLine();
  226.       } catch (Throwable var4) {
  227.          throw var4;
  228.       }
  229.  
  230.    }
  231.  
  232.    public void println(String x) {
  233.       synchronized(super.lock){}
  234.  
  235.       try {
  236.          this.print(x);
  237.          this.newLine();
  238.       } catch (Throwable var4) {
  239.          throw var4;
  240.       }
  241.  
  242.    }
  243.  
  244.    public void println(boolean x) {
  245.       synchronized(super.lock){}
  246.  
  247.       try {
  248.          this.print(x);
  249.          this.newLine();
  250.       } catch (Throwable var4) {
  251.          throw var4;
  252.       }
  253.  
  254.    }
  255.  
  256.    protected void setError() {
  257.       this.trouble = true;
  258.    }
  259.  
  260.    public void write(char[] buf) {
  261.       this.write((char[])buf, 0, buf.length);
  262.    }
  263.  
  264.    public void write(char[] buf, int off, int len) {
  265.       try {
  266.          synchronized(super.lock){}
  267.  
  268.          try {
  269.             this.ensureOpen();
  270.             this.out.write(buf, off, len);
  271.          } catch (Throwable var8) {
  272.             throw var8;
  273.          }
  274.       } catch (InterruptedIOException var9) {
  275.          Thread.currentThread().interrupt();
  276.       } catch (IOException var10) {
  277.          this.trouble = true;
  278.       }
  279.  
  280.    }
  281.  
  282.    public void write(int c) {
  283.       try {
  284.          synchronized(super.lock){}
  285.  
  286.          try {
  287.             this.ensureOpen();
  288.             this.out.write(c);
  289.          } catch (Throwable var6) {
  290.             throw var6;
  291.          }
  292.       } catch (InterruptedIOException var7) {
  293.          Thread.currentThread().interrupt();
  294.       } catch (IOException var8) {
  295.          this.trouble = true;
  296.       }
  297.  
  298.    }
  299.  
  300.    public void write(String s) {
  301.       this.write((String)s, 0, s.length());
  302.    }
  303.  
  304.    public void write(String s, int off, int len) {
  305.       try {
  306.          synchronized(super.lock){}
  307.  
  308.          try {
  309.             this.ensureOpen();
  310.             this.out.write(s, off, len);
  311.          } catch (Throwable var8) {
  312.             throw var8;
  313.          }
  314.       } catch (InterruptedIOException var9) {
  315.          Thread.currentThread().interrupt();
  316.       } catch (IOException var10) {
  317.          this.trouble = true;
  318.       }
  319.  
  320.    }
  321. }
  322.